<?php
class IncrementDataHandle extends AbsDataHandle {
	private static $options = array(
		'start' => 1,
		'step' => 1,
		'sig' => 'default',
	);
	
	public static function getType() {
		return 'increment';
	}
	
	public static function handle($defineCfg) {
		$options = (isset($defineCfg['options']) && is_array($defineCfg['options'])) ? $defineCfg['options'] : array();
		
		$options = array_merge(self::$options, $options);
		
		return self::genData($options);
	}
	
	private static function genData($options) {
		static $dataArr = array();
		$sig = md5('sig-' . $options['sig']);
		if(isset($dataArr[$sig])) {
			$dataArr[$sig] += $options['step'];
		} else {
			$dataArr[$sig] = $options['start'];
		}
		
		return $dataArr[$sig];
	}
}
?>